#pragma once

#include "ui_TraderMaster.h"
#include <QWidget>
#include <QSettings>
#include <QSplitter>
#include <QDockWidget>
#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QTableWidget>
                     
#include "TrQTypes.h"
#include "TrLogger.h"
#include "TrLoader.h"
#include "TrMarket.h"
#include "DockManager.h"
#include "TrTableMaster.h"
#include "TrChartMain.h"


#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif

class TraderMaster : public QMainWindow
{
    Q_OBJECT

public:
    TraderMaster(QWidget *parent = nullptr);
    ~TraderMaster();
    void create_dock_master();
    void create_dock_concerned();

protected:
    void    timerEvent(QTimerEvent* event) override;
    void    closeEvent(QCloseEvent* event) override;
    void    add_market_filter(const std::string& code);
protected slots:
    void    create_dock_chartmain(QString code);
    void    Slot_OnActivated(QSystemTrayIcon::ActivationReason reason);
    void    Slot_MarketOff();
    void    Slot_MasterCheckCode(QString code);
private:
    Ui::TraderMasterClass ui;
    void    init_layout();
    void    init_settings();
    void    init_tray();
    void    create_market(const QString& _path);
    void    destroy_market();
    void    init_tableUI();

    QSystemTrayIcon*            m_sysTray;
    SpdLoggerPtr                m_Logger;
    ads::CDockManager*          m_pDockManger;
    TrMarket*                   m_MarketPtr = nullptr;
    std::vector<std::string>    m_vecFilterCodes;
    int                         m_timerId;
    ads::CDockWidget*           m_pDockWidget_TableMaster = nullptr;
    ads::CDockWidget*           m_pDockWidget_TableConcerned = nullptr;
    QMap<QString, ads::CDockWidget*> m_mapChartMain;
public:
    QString                     m_strMasterRuleFile;
    
};
